#include <iostream.h>
#include "string2.h"
#include "vector.h"

void main ()
{
  cout << "Case 1: Create a numvec object with no name and apply all public";
  cout << " operations. Default array size is five." << endl;
  Numvec test1;
  cout << "Set max value = 240.01 and min value = 10.2 for test set #1" << endl;
  test1.set_max (240.01);
  test1.set_min (10.2);
  cout << "Adding 10.2, 96.789, 110.002, 193.34, 240.0" << endl << endl;
  test1.add_item ("10.2"); test1.add_item ("96.789"); test1.add_item ("110.002");
  test1.add_item ("193.34"); test1.add_item ("240.0");
  test1.print ();
  cout << "Max value: " << test1.get_max () << " Min value: " << test1.get_min () << endl;
  cout << "Current_size: " << test1.get_size () << endl;
  cout << "Testing setting and getting the name of the object." << endl;
  cout << "Object name: " << test1.get_name () << endl;
  cout << "Changing object name to Test1..." << endl;
  test1.set_name ("Test1");
  cout << "Object's new name: " << test1.get_name () << endl;
  cout << "Testing getting the i th item operation" << endl;
  cout << "4th data item in the vector: " << test1.get (4) << endl;
  cout << "Testing array expansion. A message stating the array has been expanded";
  cout << " will be" <<  endl << "printed out." << endl;
  cout << "Adding 34.23 and 43.23" << endl;
  test1.add_item ("34.23"); test1.add_item ("43.23");
  test1.print ();
  cout << "New size: " << test1.get_size () << endl;
  cout << "Check to see if 101.032 is valid." << endl;
  if (test1.valid (101.032))
	cout << "TRUE" << endl;
  else
	cout << "FALSE" << endl;
  cout << "Check to see if 300.01 is valid." << endl;
  if (test1.valid (300.01))
	cout << "TRUE" << endl;
  else
	cout << "FALSE" << endl;
  cout << "Change max value to 400.98 and min value to 5.6" << endl;
  test1.set_max (400.98); test1.set_min (5.6);
  cout << "New max value: " << test1.get_max () << ";  New min value: ";
  cout << test1.get_min () << endl;
  cout << "Adding 6.4 and 390.34 to Test1" << endl;
  test1.add_item ("6.4"); test1.add_item ("390.34");
  test1.print ();

  cout << "Case 2: Changing max value to less than the old max value and change" << endl;
  cout << "the min value to greater than it was before.  An error message should" << endl;
  cout << "be print out and the max and min values are not changed." << endl;
  cout << "Test1 max value: " << test1.get_max () << ";  min value: ";
  cout << test1.get_min () << endl;
  cout << "Change min to 10.2 and max to 200.97" << endl;
  test1.set_min (10.2); test1.set_max (200.97);
  cout << "Results.  Test1 max value: " << test1.get_max () << ";  min value: ";
  cout << test1.get_min () << endl;

  cout << "Case 3: Try to get an data whose position is greater than the size of";
  cout << " the vector." << endl << "-1 will be returned." << endl;
  cout << "Result: " << test1.get (12) << endl;

  cout << "Case 4: Try to add data that are less than min value or greater than";
  cout << " max value." << endl << "FALSE will be returned by the add member function." << endl;
  cout << "Trying to add 1.2 to Test1: ";
  if ((test1.add_item ("1.2")) == FALSE)
	cout << "FALSE" << endl;
  else
	cout << "TRUE" << endl;
  cout << "Trying to add 999.99 to Test1: ";
  if ((test1.add_item ("999.99")) == FALSE)
	cout << "FALSE" << endl;
  else
	cout << "TRUE" << endl;

  cout << "Case 5: Create an object with a name, min value of 10.0, max value of" << endl;
  cout << " 100.0 and initial vector size of 5.  Repeat all tests in case 1." << endl;
  Numvec test2 ("Test_set #2", 100.0, 10.0, 5);
  cout << "Adding 10.2, 46.789, 70.002, 83.34, 94.0" << endl << endl;
  test2.add_item ("10.2"); test2.add_item ("46.789"); test2.add_item ("70.002");
  test2.add_item ("83.34"); test2.add_item ("94.0");
  test2.print ();
  cout << "Max value: " << test2.get_max () << " Min value: " << test2.get_min () << endl;
  cout << "Current_size: " << test2.get_size () << endl;
  cout << "Testing setting and getting the name of the object." << endl;
  cout << "Object name: " << test2.get_name () << endl;
  cout << "Changing object name to Test2..." << endl;
  test2.set_name ("Test2");
  cout << "Object's new name: " << test2.get_name () << endl;
  cout << "Testing getting the i th item operation" << endl;
  cout << "4th data item in the vector: " << test2.get (4) << endl;
  cout << "Testing array expansion. A message stating the array has been expanded";
  cout << " will be" <<  endl << "printed out." << endl;
  cout << "Adding 34.23 and 43.23" << endl;
  test2.add_item ("34.23"); test2.add_item ("43.23");
  test2.print ();
  cout << "New size: " << test2.get_size () << endl;
  cout << "Check to see if 101.032 is valid." << endl;
  if (test2.valid (91.032))
	cout << "TRUE" << endl;
  else
	cout << "FALSE" << endl;
  cout << "Check to see if 300.01 is valid." << endl;
  if (test2.valid (300.01))
	cout << "TRUE" << endl;
  else
	cout << "FALSE" << endl;
  cout << "Change max value to 400.98 and min value to 5.6" << endl;
  test2.set_max (400.98); test2.set_min (5.6);
  cout << "New max value: " << test2.get_max () << ";  New min value: ";
  cout << test2.get_min () << endl;
  cout << "Adding 6.4 and 390.34 to test2" << endl;
  test2.add_item ("6.4"); test2.add_item ("390.34");
  test2.print ();

  cout << "Case 6: Testing the copy initializer.  Test set #3 will be created by";
  cout << " using test set #1" << endl << "as the arguement." << endl;
  cout << "Creating test set #3..." << endl;
  Numvec test3 (test1);
  cout << "Test set #1..." << endl;
  test1.print ();
  cout << "Max value: " << test1.get_max () << ";  min value: " << test1.get_min () << endl;
  cout << "Test set #3..." << endl;
  test3.print ();
  cout << "Max value: " << test3.get_max () << ";  min value: " << test3.get_min () << endl;
  cout << "Adding 50.34 to test set #1 and 67.5968 to test set #3." << endl;
  test1.add_item ("50.34"); test3.add_item ("67.5968");
  cout << "New test set #1..." << endl;
  test1.print ();
  cout << "New test set #3..." << endl;
  test3.print ();

  cout << "Case 7: Testing Codevec class.  Creating a Codevec with no arguements";
  cout << "and apply" << endl << "all public operatons.  Vector/Allowable vector size = 5." << endl;
  cout << "Creating test set #4..." << endl;
  Codevec test4;
  test4.print ();
  cout << "Test set #4 vector size: " << test4.get_size ();
  cout << "Change test set #4's name to Test4." << endl;
  test4.set_name ("Test4");
  cout << "New name: " << test4.get_name () << endl;
  cout << "Adding chemistry, physics, math, compsci and economics as allowable";
  cout << "strings." << endl;
  test4.add_allowed ("chemistry"); test4.add_allowed ("physics");
  test4.add_allowed ("math"); test4.add_allowed ("compsci");
  test4.add_allowed ("economics");
  cout << "Adding strings chemistry, physics, math, compsci and economics as data";
  cout << "strings." << endl;
  test4.add_item ("chemistry"); test4.add_item ("physics");
  test4.add_item ("math"); test4.add_item ("compsci"); test4.add_item ("economics");
  test4.display_allowed ();
  test4.print ();
  cout << "Current size: " << test4.get_size () << endl;
  cout << "4th item in the vector: " << test4.get (4) << endl;
  cout << "Testing array expansion. Adding string math to the data vector." << endl;
  test4.add_item ("math");
  test4.print ();
  cout << "Current size: " << test4.get_size () << endl;
  cout << "Adding string biology to the allowable vector." << endl;
  test4.add_allowed ("biology");
  test4.display_allowed ();
  cout << "Checking to see if biology is an allowable string: ";
  if (test4.valid ("biology"))
    cout << "TRUE." << endl;
  else
    cout << "FALSE." << endl;
  cout << "Checking to see if psychology is an allowable string: ";
  if (test4.valid ("psychology"))
    cout << "TRUE." << endl;
  else
    cout << "FALSE." << endl;

  cout << "Case 8: Trying to add an invalid string to the data vector.  FALSE";
  cout << " should" << endl << "be returned." << endl;
  cout << "Adding string psychology. Result: ";
  if (test4.add_item ("psychology"))
    cout << "TRUE." << endl;
  else
    cout << "FALSE." << endl;
    
  cout << "Case 9: Try to get an item whose position is beyond the size of the";
  cout << "vector," << endl << "null string should be returned." << endl;
  cout << "Trying to get data at position 12, result: " << test4.get (12) << endl;
  
  cout << "Case 10: Create a Codevec object with an initial name and repeat";
  cout << "tests in case 7." << endl;
  Codevec test5 ("Test set #5");
  test5.print ();
  cout << "Test set #5 vector size: " << test5.get_size ();
  cout << "Change test set #5's name to Test5." << endl;
  test5.set_name ("Test5");
  cout << "New name: " << test5.get_name () << endl;
  cout << "Adding chemistry, physics, math, compsci and economics as allowable";
  cout << "strings." << endl;
  test5.add_allowed ("chemistry"); test5.add_allowed ("physics");
  test5.add_allowed ("math"); test5.add_allowed ("compsci");
  test5.add_allowed ("economics");
  cout << "Adding strings chemistry, physics, math, compsci and economics as data";
  cout << "strings." << endl;
  test5.add_item ("chemistry"); test5.add_item ("physics");
  test5.add_item ("math"); test5.add_item ("compsci"); test5.add_item ("economics");
  test5.display_allowed ();
  test5.print ();
  cout << "Current size: " << test5.get_size () << endl;
  cout << "4th item in the vector: " << test5.get (4) << endl;
  cout << "Testing array expansion. Adding string math to the data vector." << endl;
  test5.add_item ("math");
  test5.print ();
  cout << "Current size: " << test5.get_size () << endl;
  cout << "Adding string biology to the allowable vector." << endl;
  test5.add_allowed ("biology");
  test5.display_allowed ();
  cout << "Checking to see if biology is an allowable string: ";
  if (test5.valid ("biology"))
    cout << "TRUE." << endl;
  else
    cout << "FALSE." << endl;
  cout << "Checking to see if psychology is an allowable string: ";
  if (test5.valid ("psychology"))
    cout << "TRUE." << endl;
  else
	cout << "FALSE." << endl;

  cout << "Case 11: Testing copy initializer. Test set #6 will be created with";
  cout << "test set #4" << endl << "as an arguement." << endl;
  Codevec test6 (test4);
  test4.display_allowed ();
  test4.print ();
  cout << "Test set #4's size: " << test4.get_size () << endl;
  test6.display_allowed ();
  test6.print ();
  cout << "Test set #6's size: " << test6.get_size () << endl;
  cout << "Adding chinese as an allowable string and math as a data string to test";
  cout << " set #4." << endl;
  test4.add_allowed ("chinese"); test4.add_item ("math");
  test4.display_allowed ();
  test4.print ();
  cout << "Adding psychology as an allowable string and psychology as a data string to";
  cout << " test set #6." << endl;
  test6.add_allowed ("psychology"); test6.add_item ("psychology");
  test6.display_allowed ();
  test6.print ();

  cout << "Case 12: Testing the assignment operator.  Test set #7 will be created and";
  cout << " set equal to" << endl << "test set #1." << endl;
  cout << "Creating test set #7..." << endl;
  Numvec test7;
  test7 = test1;
  cout << "Test set #1..." << endl;
  test1.print ();
  cout << "Max value: " << test1.get_max () << ";  min value: " << test1.get_min () << endl;
  cout << "Test set #7..." << endl;
  test7.print ();
  cout << "Max value: " << test7.get_max () << ";  min value: " << test7.get_min () << endl;
  cout << "Adding 50.34 to test set #1 and 67.5968 to test set #7." << endl;
  test1.add_item ("50.34"); test7.add_item ("67.5968");
  cout << "New test set #1..." << endl;
  test1.print ();
  cout << "New test set #7..." << endl;
  test7.print ();

  cout << "Case 13: Testing assignment operator. Test set #8 will be created and";
  cout << "set equal to" << endl << "test set #4." << endl;
  Codevec test8;
  test8 = test4;
  test4.display_allowed ();
  test4.print ();
  cout << "Test set #4's size: " << test4.get_size () << endl;
  test8.display_allowed ();
  test8.print ();
  cout << "Test set #8's size: " << test8.get_size () << endl;
  cout << "Adding chinese as an allowable string and math as a data string to test";
  cout << " set #4." << endl;
  test4.add_allowed ("chinese"); test4.add_item ("math");
  test4.display_allowed ();
  test4.print ();
  cout << "Adding psychology as an allowable string and psychology as a data string to";
  cout << " test set #8." << endl;
  test8.add_allowed ("psychology"); test8.add_item ("psychology");
  test8.display_allowed ();
  test8.print ();
  
  cout << endl << "Case 14: Testing inheritance of the vector class." << endl;
  
}